<template>
  <div>
    <el-card v-for="(d, index) in dataList" :key="d.formItemId">
      <div slot="header">
        <h4 class="left-border">{{ index + 1 + '.' + d.title }}</h4>
      </div>
      <el-table :data="d.detailList" :header-cell-style="{ 'font-size': '16px' }" style="font-size: 16px" stripe>
        <el-table-column :label="columnName" prop="evaluatedName"></el-table-column>
        <el-table-column label="得分" prop="average" align="center" sortable></el-table-column>
        <el-table-column label="平均分" prop="totalAverage" align="center"></el-table-column>
        <el-table-column label="分值差" align="center">
          <template v-slot="scope">
            <span :class="scope.row.average - scope.row.totalAverage >= 0 ? 'green' : 'red'">
              {{ (scope.row.average - scope.row.totalAverage) | numFilter }}
            </span>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import { getRequest } from '@/api/baseRequest'

export default {
  name: 'FormItemList',
  props: ['formKey', 'type', 'dataList'],
  computed: {
    columnName() {
      if (this.type == 5) {
        return '被评价部门'
      } else if (this.type == 6) {
        return '被评价人'
      }
      return '名称'
    }
  },
  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      let realVal = parseFloat(value).toFixed(2)
      return realVal
    }
  },
  created() {
    // this.getDataList()
  },
  data() {
    return {
      // dataList: []
    }
  },
  methods: {
    /*getDataList() {
            getRequest('/report/getItemScore', {formKey: this.formKey}).then((res) => {
                if (res.code == 200) {
                    this.dataList = res.data
                }
            })
        }*/
  }
}
</script>

<style scoped>
.left-border {
  border-left: 5px blue solid;
  padding-left: 10px;
}
.red {
  color: #ff6161;
}

.green {
  color: #39b895;
}
</style>
